// config/config.default.js
'use strict';

module.exports = appInfo => {
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1637654321098_8765';

  // add your config here
  config.middleware = [
    'errorHandler',
    'organizationPermissionMiddleware'
  ];

  // 安全配置
  config.security = {
    csrf: {
      enable: false,
    },
  };

  // CORS配置
  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
  };

  // JWT配置
  config.jwt = {
    secret: 'lingxi-system-jwt-secret',
  };

  // Redis配置
  config.redis = {
    client: {
      port: 6379,
      host: '127.0.0.1',
      password: '',
      db: 0,
    },
  };

  // 数据库配置
  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    port: 3306,
    database: 'lingxi_system',
    username: 'root',
    password: '888mei525',
    timezone: '+08:00',
    define: {
      charset: 'utf8mb4',
      dialectOptions: {
        collate: 'utf8mb4_unicode_ci',
      },
      timestamps: true,
    },
  };

  // 上传文件配置
  config.multipart = {
    mode: 'file',
    fileSize: '50mb',
    fileExtensions: ['.csv', '.xlsx', '.xls'],
  };

  // 日志配置
  config.logger = {
    level: 'INFO',
    consoleLevel: 'INFO',
  };

  // 政采云API配置
  config.zcyApi = {
    baseUrl: 'https://api.zcygov.cn', // 政采云API基础URL
    apiKey: '', // API密钥，开发环境可为空
  };

  // 服务器端口配置
  config.cluster = {
    listen: {
      port: 9001,
      hostname: '127.0.0.1',
    },
  };

  return {
    ...config,
  };
};